<template>
  <div>
    <el-card shadow="never" class="card">
      <div slot="header" class="clearfix">
        <span>简历投递情况</span>
        <span style="padding-left: 56%">当前共有 <el-button type="primary" size="mini"
                                                        round>{{ page_data.page_total }}</el-button>份简历，其中已经受理的有<el-button
            type="success" size="mini" round>{{ page_data.tg }}</el-button>份</span>
      </div>
      <div id="charts_one" style="width:100%;min-height:300px">
        <el-button
            type="danger"
            size="small"
            icon="el-icon-finished"
            :disabled="selection_button_state"
            @click="show_selection"
        >{{ selection_button_title }}
        </el-button>
        <el-select v-model="value" placeholder="状态" style="width: 100px; margin-left: 50%">
          <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
          </el-option>
        </el-select>
        <el-input v-model="name" placeholder="公司/岗位" style="width: 160px; margin-left: 6px"></el-input>

        <el-button type="primary" icon="el-icon-search" style="margin-left: 10px;" @click="seach">搜索</el-button>

        <el-table
            size="small"
            :data="user_data"
            max-height="350"
            @selection-change="selection"
            style="width: 100%"
            align="center"
        >
          <el-table-column type="selection" width="55" align="center"></el-table-column>
          <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
          <el-table-column property="enterInfo.cname" label="公司名称" width="240" align="center"></el-table-column>
          <el-table-column property="gname" label="岗位名称" align="center"></el-table-column>
          <el-table-column property="type" label="岗位类型" align="center"></el-table-column>
          <el-table-column property="salary" label="薪资" align="center"></el-table-column>
          <el-table-column property="enterInfo.tel" label="电话" align="center"></el-table-column>
          <el-table-column property="resume.status" label="状态" align="center"></el-table-column>

          <el-table-column label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button size="mini" type="success" @click="editor_user(scope.row.resume.tid,scope.row.resume.wid,scope.row.resume.uid)">
                <i class="el-icon-edit-outline"/>
              </el-button>
              <el-popconfirm
                  confirmButtonText="确认删除"
                  cancelButtonText="取消"
                  confirmButtonType="danger"
                  cancelButtonType="success"
                  @onConfirm="delete_user(scope.row.resume.tid,scope.row.resume.wid,scope.row.resume.uid)"
                  title="您确定删除该信息吗？"
              >
                <el-button size="mini" slot="reference" type="danger">
                  <i class="el-icon-delete"/>
                </el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>

        <el-pagination
            @size-change="page_size_change"
            @current-change="current_change"
            :current-page="page_data.page_num"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="page_data.row_num"
            layout="total, sizes, prev, pager, next, jumper"
            :total="page_data.page_total"
            style="margin-top:10px"
        ></el-pagination>
      </div>
    </el-card>
    <el-dialog :title="dialog_title" :visible.sync="dialog_viside_state">
      <el-form ref="form" :model="user_form" label-width="80px">
        <el-form-item label="状态：">
          <span>{{resume_status}}</span>
        </el-form-item>
        <el-form-item label="回馈信息:">
          <span v-html="resume_info"></span>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      dialog_viside_state: false,
      password_input_state: false,
      selection_button_title: "未选择数据",
      selection_button_state: true,
      selection_data: [],
      options: [
          {
        value: '通过',
        label: '通过'
      }, {
          value: '未通过',
          label: '未通过'
        }],
      value: '',
      name:'',
      dialog_title: "",
      resume_status:'',
      resume_info:'',
      user_data: [],
      page_data: {
        row_num: 10,
        page_num: 1,
        page_total: 0,
        tg: 0,
      },
    };
  },
  methods: {
    editor_user(_tid,_wid,_uid) {
      this.dialog_title = "受理详情";
      this.dialog_viside_state = true;
      this.$axios({
        url: this.$axios.defaults.baseURL+"/student/resumeinfo",
        method: "get",
        params: {
          tid: _tid,
          wid:_wid,
          uid:_uid,
        }
      }).then(res => {
        this.resume_status = res.data.status;
        this.resume_info = res.data.infomation;
      })
    },
    selection(select_data) {
      if (
          select_data.length > 0 &&
          this.user_data.length != select_data.length
      ) {
        this.selection_button_title = "已选择" + select_data.length;
        this.selection_button_state = false;
        this.selection_data = select_data;
      } else if (this.user_data.length == select_data.length) {
        this.selection_button_title = "删除选中";
        this.selection_button_state = false;
        this.selection_data = select_data;
      } else {
        this.selection_button_title = "未选择数据";
        this.selection_button_state = true;
      }
    },
    delete_user(_tid,_wid,_uid) {
      this.$axios({
        url: this.$axios.defaults.baseURL+"/student/delresume",
        method: "get",
        params: {
          tid: _tid,
          wid:_wid,
          uid:_uid,
        }
      }).then(res => {
        if(res.data){
          this.$message.success("删除成功");
          this.get_user_data(10, 1);
        }else {
          this.$message.error("删除失败，请稍后尝试！");
        }
      })
    },
    show_selection() {
      this.$message.success("已打印选择数据成功，请打开检查查看");
      console.log(this.selection_data);
    },
    page_size_change(row_num) {
      this.page_data.row_num = row_num;
      this.$message.success('每页显示' + row_num + '条数据')
      this.get_user_data()
    },
    current_change(click_page) {
      this.page_data.page_num = click_page
      this.$message.success('正在展示第' + click_page + '页数据')
      this.get_user_data(this.row_num, click_page)
    },
    seach(){
      this.get_user_data(10,1)
    },
    get_user_data(_row, _currenpag) {
      //发送请求
      this.$axios({
        url: this.$axios.defaults.baseURL+"/student/selectresume",
        method: "get",
        params: {
          row: _row,
          currenpag: _currenpag,
          status : this.value,
          name:this.name,
          uid:sessionStorage.getItem("studentuid")
        }
      }).then(res => {
        this.user_data = res.data.list;
        this.page_data.page_total = res.data.total;
        this.page_data.tg = res.data.tg;
      })
    },
  },

  mounted() {
    this.get_user_data(10, 1);
  },
};
</script>